package com.atguigu.gmall.product.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 李旭
 * @create: 2021-09-30 15:29
 **/
@Controller
@RequestMapping("/hello")
public class HelloController {

    //进入页面
    @GetMapping("/h")
    public String h(Model model, HttpSession httpSession){

        model.addAttribute("hello","世界你好");
        List<String> list = new ArrayList<>();
        list.add("曾志伟");
        list.add("周发发");
        list.add("周星昨");
        list.add("华仔");
        model.addAttribute("list",list);
        model.addAttribute("num",12);

        httpSession.setAttribute("ses","我是Session的值");

        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");

        return "hello";
    }

}
